import datetime  
import time
from watchdog.observers import Observer  
from watchdog.events import FileSystemEventHandler
class MyHandler(FileSystemEventHandler):  
    # def on_modified(self, event):  
    #     print(f"文件 {event.src_path} 被修改")
    def on_created(self,event):
        print(datetime.datetime.now(),f"文件 {event.src_path} 被创建")
if __name__ == "__main__":  
   event_handler = MyHandler()  
   observer = Observer()  
   path=r'\\10.0.114.230\化学分析室\仪器采集\caiji\ajl5110_back'
   # path="d:\\ma"
   observer.schedule(event_handler, path=path, recursive=False)  
   observer.start()  
   try:  
       while True:  
           time.sleep(1)  
   except KeyboardInterrupt:  
       observer.stop()  
   observer.join()